package com.yang.strategy.client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Map;
import java.util.Set;

/**
 * @author yangyongsheng
 * @date 2024/6/23 22:42
 * @description beacon-cache远程调用客户端
 */
@FeignClient("beacon-cache")//属性要和spring.application.name对应
public interface BeaconCacheClient {

    @GetMapping("/cache/hgetall/{key}")
    Map hGetAll(@PathVariable(value = "key") String key);

    @GetMapping("/cache/hget/{key}/{field}")
    Object hget(@PathVariable(value = "key") String key, @PathVariable(value = "field") String field);

    //方法重载，
    @GetMapping("/cache/hget/{key}/{field}")
    String hgetString(@PathVariable(value = "key") String key, @PathVariable(value = "field") String field);

    @GetMapping("/cache/smember/{key}")
    Set<String> smember(@PathVariable(value = "key") String key);

    //方法重载，让openfeign去帮忙转换
    @GetMapping("/cache/smember/{key}")
    Set<Map> smemberMap(@PathVariable(value = "key") String key);

    //方法重载，让openfeign去帮忙转换
    @PostMapping("/cache/get/{key}")
    String getString(@PathVariable(value = "key") String key);

    @PostMapping(value = "/cache/sinterstr/{key}/{sinterKey}")
    Set<Object> sinterStr(@PathVariable(value = "key") String key, @PathVariable(value = "sinterKey") String sinterKey
            , @RequestBody String... value);

    @GetMapping("/cache/hget/{key}/{field}")
    Integer hgetInteger(@PathVariable(value = "key") String key, @PathVariable(value = "field") String field);

    @PostMapping(value = "/cache/zadd/{key}/{score}/{member}")
    Boolean zadd(@PathVariable(value = "key") String key, @PathVariable(value = "score") Long score, @PathVariable(value = "member") Object member);

    @PostMapping(value = "/cache/zrangebyscore/{key}/{min}/{max}")
    Integer zrangebyscore(@PathVariable(value = "key") String key
            , @PathVariable(value = "min") Double min
            , @PathVariable(value = "max") Double max);

    @PostMapping(value = "/cache/zremove/{key}/{member}")
    void zremove(@PathVariable(value = "key") String key, @PathVariable(value = "member") Object member);

    @PostMapping(value = "/cache/hincrby/{key}/{field}/{increment}")
    Long hincrby(@PathVariable(value = "key") String key, @PathVariable(value = "field") String field, @PathVariable(value = "increment") Long increment);
}
